package com.example.readwriteexample.controller;

import com.example.readwriteexample.dal.model.TOrder;
import com.example.readwriteexample.service.ITOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    ITOrderService orderService;

    @GetMapping("/{id}")
    public TOrder order(@PathVariable("id") Long id) {
        TOrder order = orderService.getById(id);
        return order;
    }

    @PostMapping
    public void order(@RequestBody TOrder order) {
        orderService.save(order);
    }
}
